/*
 * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & dreamlu.net).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ironman.mes.plugin.common.properties;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;

import java.util.ArrayList;
import java.util.List;

/**
 * description
 * company 铁人科技
 *
 * @author 陈浩杰
 * @date 2024/11/9 16:30
 */
@Inject("${mqtt.client}")
@Configuration
@Setter
@Getter
public class MqttClientProperties {

    private boolean enabled = true;

    /**
     * 名称，默认：Mica-Mqtt-Client
     */
    private String name = "Mica-Mqtt-Client";

    /**
     * 服务端 ip，默认：127.0.0.1
     */
    private String ip = "127.0.0.1";

    /**
     * 端口，默认：1883
     */
    private int port = 1883;

    /**
     * 客户端ID
     */
    private String clientId;

    /**
     * 用户名
     */
    private String userName;
    /**
     * 密码
     */
    private String password;

    /**
     * Keep Alive (s)
     */
    private int keepAliveSecs = 60;

    /**
     * 连续重连次数，当连续重连这么多次都失败时，不再重连。0和负数则一直重连
     */
    private int retryCount = 0;

    /**
     * 订阅主题列表
     */
    private List<Topic> topics = new ArrayList<>();

    @Data
    public static class Topic {

        private String topic;

        private int qos;
    }
}
